Skip to content

Fix posix_getgrnam()/posix_getgrgid() crash on NULL group name#22433

Closed
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:posix-group-name-null
Closed

Fix posix_getgrnam()/posix_getgrgid() crash on NULL group name#22433
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:posix-group-name-null

Conversation

@iliaal

@iliaal iliaal commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

php_posix_group_to_array() passes gr_name straight to add_assoc_string() with no NULL guard, so a NULL group name segfaults via zend_string_init(). The sibling gr_passwd field right below is already guarded.

glibc's files NSS backend normalizes empty fields to the empty string, but third-party NSS modules (nss-systemd, nss-ldap, sssd and other directory backends) populate struct group directly and may leave gr_name NULL.

The field is now guarded and emits null instead, matching the existing gr_passwd handling. Companion to #22426, which guarded the equivalent fields in the passwd array.

php_posix_group_to_array() passed gr_name straight to add_assoc_string()
with no NULL guard, so a NULL group name segfaults via zend_string_init(),
while the sibling gr_passwd field right below is already guarded. glibc's
files NSS backend normalizes empty fields to "", but third-party NSS
modules (nss-systemd, nss-ldap, sssd and other directory backends)
populate struct group directly and may leave gr_name NULL. Guard it and
emit null instead, matching the existing gr_passwd handling.
@iliaal iliaal closed this in be55be0 Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants